import book.Book;
import booklist.BookList;
import operation.*;
import user.*;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-04-10
 * Time: 15:59
 */
public class Main {
    //登录
    public static User login() {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入姓名");
        String name = scan.nextLine();
        System.out.println("请输入你的身份： 1：管理员  2：普通用户");
        do {
            int choice = scan.nextInt();
            if (choice == 1) {
                //创建管理员用户的实例
                return new AdminUser(name);
            } else if (choice == 2) {
                //创建普通用户的实例
                return new NormalUser(name);
            } else {
                System.out.println("输入错误，请重新输入！");
            }
        }while(true);
    }

    public static void main(String[] args) {
        //输入姓名，与身份选择
        User user = login();
        BookList books = new BookList();
        while(true) {
            //根据选择显示相应的菜单
            int choice = user.menu();
            //实现相应菜单中的相应功能
            user.doOperation(choice,books);
        }
    }
}
